#include<string.h>
#include<stdlib.h>
#include<ctype.h>
#include<math.h>
#include<iostream.h>


int hex2num (char *str)
{
  int m,i = 0;
  int num=0;
  for(i=0;i<4;i++)
   {
    switch (toupper(str[i]))
     {
      case 'A':m=10;break;
      case 'B':m=11;break;
      case 'C':m=12;break;
      case 'D':m=13;break;
      case 'E':m=14;break;
      case 'F':m=15;break;
      default :m=str[i]-48;
     }
    num+=pow(16,3-i)*m;
   }
 return(num);
}

